package com.yanqu.road.server.manger.activity.greattrade;

import com.yanqu.road.dao.impl.activity.greattrade.GreatTradeConfigDaoImpl;
import com.yanqu.road.entity.activity.ActivityConfig;
import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.greattrade.GreatTradeSimpleStatus;
import com.yanqu.road.entity.activity.greattrade.UserGreatTradeData;
import com.yanqu.road.entity.activity.greattrade.config.*;
import com.yanqu.road.entity.enums.eActivityConfigType;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.utils.RandomHelper;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class GreatTradeConfig {

    private ActivityInfo activityInfo;

    List<GreatTradeEventInfo> eventInfoList;

    List<GreatTradeGoodsInfo> goodsInfoList;

    List<GreatTradeSkillsInfo> skillsInfoList;

    List<GreatTradeTitleInfo> titleInfoList;

    List<GreatTradeUnlockSkillInfo> unlockSkillInfoList;

    //每日免费开启次数
    int freeNum = 3;
    //开启道具id
    int openItemId = 120909;
    //开启消耗道具数量
    int openItemNum = 1;
    //背包初始格数
    int bagCellBiginNum = 100;
    //背包最大格数
    int bagCellMax = 300;
    //背包开格消耗现银（每次）
    List<Long> bagCellCostList;
    //每次购买的格子数量
    List<Integer> bagCellBuyNumList;
    //出生随机家境
    List<Integer> birthFamily;
    //出生初始年龄
    int birthOld = 20;

    int dieOld = 70;
    //出生初始现银
    long birthMoney = 1000;
    //健康最大值
    int healthyMax = 100;
    //每经过{0}年流失{1}点健康
    List<Integer> healthyLoseYear;
    //每出售{0}次商品流失{1}点健康
    List<Integer> healthyLoseSell;
    //每外出{0}次流失{1}点健康
    List<Integer> healthyLoseOut;
    //健康值区间对应的患病概率
    List<String> healthyIllPro;
    //每次患病无法操作的回合数（最小值 | 最大值）随机
    List<Integer> healthyIllDismove;
    //每年随机事件出现概率（千分比）
    int eventPro = 300;
    //每年能出现的随机事件权重：最小回合数；事件列表=权重|回合数；……
    List<String> eventWeight;
    //寿辰事件名望区间对应获取现银系数
    List<String> eventBirthdayMoneyParam;
    //每{0}回合增加{1}外出次数
    List<Integer> outAddNum;
    //外出最大次数限制
    int outMax = 5;
    //外出地点随机权重：医馆|酒楼|御街|黑市
    List<Integer> outWeightPlace;
    //老中医和入殓师事件遇到权重（事件类型=权重|事件类型=权重）
    List<String> outWeightHospital;
    //医馆事件参数：健康回复消耗现银基础值 | 健康回复现银每次增长率（千分比） | 换取现银消耗健康值 | 换取现银系数（整数）
    List<Integer> outParamHospital;
    //诗会和宴会事件遇到权重
    List<String> outWeightRestaurant;
    //刀圣翻牌现银消耗（千分比）：第一次 | 第二次 | 第三次
    List<Integer> outFlopCost;
    //开宝事件名望区间：中间值
    List<Integer> outTreasurePriceCondition;
    //开宝区间对应价格：名望对应物品价格
    List<String> outTreasurePriceRange;
    //
    List<Integer> outTreasurePriceWeight;
    //卖出盐场折旧千分比|复购增幅千分比
    List<Integer> saltBuyParam;
    //盐场市场监管权重及对应风险
    List<String> saltRisk;
    //开采选项对应的 风险（千分比）； 开采量（百分比）
    List<String> saltMineRiskSpeed;
    //
    List<Integer> eventHealthyMoneyTomuch;
    //每年随机商品数量：最小数量|最大数量
    List<Integer> buyRandomNumList;
    //继承点道具
    int beautySkillUpgradeItemId = 120899;
    //宴会包场消耗
    List<Integer> outParamRestaurantList;
    //商途名望最终评价，获得继承点
    String resultFame;
    //美女美名等级增加技能等级
    List<Integer> beautyExLvList;
    //已买商品的出现概率（千分比）用于巫女美女技能的计算
    private int buyRandomPro = 625;
    //产业破产返还现银比例（千分比）
    private int industryBrokeParam = 500;
    //年龄区间对应的每年健康变化量
    private List<String> healthyChangeYear;

    public GreatTradeSkillsInfo getGreatTradeSkillsInfo(int id){
        for (GreatTradeSkillsInfo skillsInfo : skillsInfoList) {
            if(skillsInfo.getId() == id){
                return skillsInfo;
            }
        }
        return null;
    }

    public GreatTradeSkillsInfo getGreatTradeSkillsInfo(int id, int level){
        for (GreatTradeSkillsInfo skillsInfo : skillsInfoList) {
            if(skillsInfo.getId() == id && skillsInfo.getLevel() == level){
                return skillsInfo;
            }
        }
        return null;
    }

    public int getMaxGreatTradeSkillLv(int skillId){
        int num = 0;
        for (GreatTradeSkillsInfo skillsInfo : skillsInfoList) {
            if(skillsInfo.getId() == skillId){
                num++;
            }
        }
        return num;
    }

    public GreatTradeGoodsInfo getGreatTradeGoodsInfo(int id){
        for (GreatTradeGoodsInfo goodsInfo : goodsInfoList) {
            if(goodsInfo.getId() == id){
                return goodsInfo;
            }
        }
        return null;
    }

    public Map<Integer, Long> randomIndustryPrice(Map<Integer,Long> lastYear, Random random){
        Map<Integer, Long> map = new HashMap<>();
        List<GreatTradeGoodsInfo> list = new ArrayList<>();
        for (GreatTradeGoodsInfo goodsInfo : goodsInfoList) {
            if(goodsInfo.getType() == 2){
                list.add(goodsInfo);
            }
        }
        for (GreatTradeGoodsInfo goodsInfo : list) {
            List<Integer> changeWeightList = StringUtils.stringToIntegerList(goodsInfo.getChangeWeight(), "\\|");
            List<Integer> changeParamList = StringUtils.stringToIntegerList(goodsInfo.getChangeParam(), "\\|");
            int idx = RandomHelper.getRandomIndexByWeight(changeWeightList, random);
            long price = Long.valueOf(goodsInfo.getBasePrice());
            if(lastYear.containsKey(goodsInfo.getId())){
                price = lastYear.get(goodsInfo.getId());
            }
            if(idx > 1){
                int bili = random.nextInt(changeParamList.get(1)) + 1;
                price = BigDecimal.valueOf(price).multiply(BigDecimal.valueOf(1000 + bili)).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_DOWN).longValue();
            }else if(idx == 0){
                int bili = random.nextInt(changeParamList.get(0)) + 1;
                price = BigDecimal.valueOf(price).multiply(BigDecimal.valueOf(1000 - bili)).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_DOWN).longValue();
            }
            map.put(goodsInfo.getId(), price);
        }
        return map;
    }

    public Map<Integer, Integer> randomGoodsPrice(List<Integer> displayList, int upAddition, Random random) {
        Map<Integer, Integer> map = new HashMap<>();
        for(int goodsId : displayList){
            GreatTradeGoodsInfo goodsInfo = getGreatTradeGoodsInfo(goodsId);
            //涨跌权重
            List<Integer> weightList = StringUtils.stringToIntegerList(goodsInfo.getChangeWeight(), "\\|");
            int allWeight = 0;
            for (int weight : weightList) {
                allWeight += weight;
            }
            //int type = RandomHelper.getRandomIndexByWeight(weightList, random);
            int type;
            //涨概率
            int add = BigDecimal.valueOf(upAddition * allWeight).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_DOWN).intValue();
            if(allWeight <= (add + weightList.get(2)) || (add + weightList.get(2)) >= random.nextInt(allWeight)){
                //涨
                type = 2;
            }else {
                //跌平
                weightList.remove(2);
                type = RandomHelper.getRandomIndexByWeight(weightList, random);
            }
            List<String> rangeList = StringUtils.stringToStringList(goodsInfo.getChangeParam(), "\\|");
            List<Integer> range = StringUtils.stringToIntegerList(rangeList.get(type), ";");
            int addition = range.get(0) + random.nextInt(range.get(1) - range.get(0));
            map.put(goodsInfo.getId(), new BigDecimal(goodsInfo.getBasePrice()).multiply(BigDecimal.valueOf(addition)).divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_DOWN).intValue());
        }
        return map;
    }


    public ActivityInfo getActivityInfo() {
        return activityInfo;
    }

    public void setActivityInfo(ActivityInfo activityInfo) {
        this.activityInfo = activityInfo;
    }

    public int getActivityId(){
        if(activityInfo == null){
            return 0;
        }
        return activityInfo.getActivityId();
    }


    public List<GreatTradeEventInfo> getEventInfoList() {
        return eventInfoList;
    }

    public void setEventInfoList(List<GreatTradeEventInfo> eventInfoList) {
        this.eventInfoList = eventInfoList;
    }

    public List<GreatTradeGoodsInfo> getGoodsInfoList() {
        return goodsInfoList;
    }

    public void setGoodsInfoList(List<GreatTradeGoodsInfo> goodsInfoList) {
        this.goodsInfoList = goodsInfoList;
    }

    public List<GreatTradeSkillsInfo> getSkillsInfoList() {
        return skillsInfoList;
    }

    public void setSkillsInfoList(List<GreatTradeSkillsInfo> skillsInfoList) {
        this.skillsInfoList = skillsInfoList;
    }

    public List<GreatTradeTitleInfo> getTitleInfoList() {
        return titleInfoList;
    }

    public void setTitleInfoList(List<GreatTradeTitleInfo> titleInfoList) {
        this.titleInfoList = titleInfoList;
    }

    public boolean init() {

        GreatTradeConfigDaoImpl dao = new GreatTradeConfigDaoImpl();
        eventInfoList = dao.getGreatTradeEventInfoList(activityInfo.getActivityId());
        goodsInfoList = dao.getGreatTradeGoodsInfoList(activityInfo.getActivityId());
        skillsInfoList = dao.getGreatTradeSkillsInfoList(activityInfo.getActivityId());
        titleInfoList = dao.getGreatTradeTitleInfoList(activityInfo.getActivityId());
        unlockSkillInfoList = dao.getGreatTradeUnlockSkillInfoList(activityInfo.getActivityId());

        Map<String, ActivityConfig> activityConfigMap = NormalActivityMgr.getActivityConfigMap(activityInfo.getActivityId());
        if(activityConfigMap != null){
            freeNum = activityConfigMap.get(eActivityConfigType.BIGSHOP_FREE_NUM.getName()).getIntValue();
            openItemId = activityConfigMap.get(eActivityConfigType.BIGSHOP_OPEN_ITEM_ID.getName()).getIntValue();
            openItemNum = activityConfigMap.get(eActivityConfigType.BIGSHOP_OPEN_ITEM_NUM.getName()).getIntValue();
            //其他参数
            bagCellBiginNum = activityConfigMap.get(eActivityConfigType.BIGSHOP_BAG_CELL_BIGIN_NUM.getName()).getIntValue();
            //bagCellMax = activityConfigMap.get(eActivityConfigType.BIGSHOP_BAG_CELL_MAX.getName()).getIntValue();
            bagCellCostList = StringUtils.stringToLongList(activityConfigMap.get(eActivityConfigType.BIGSHOP_BAG_CELL_COST.getName()).getValue(), "\\|");
            bagCellBuyNumList = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_BAG_CELL_BUY_NUM.getName()).getValue(), "\\|");
            birthFamily = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_BIRTH_FAMILY.getName()).getValue(), "\\|");
            birthOld = activityConfigMap.get(eActivityConfigType.BIGSHOP_BIRTH_OLD.getName()).getIntValue();
            birthMoney = activityConfigMap.get(eActivityConfigType.BIGSHOP_BIRTH_MONEY.getName()).getLongValue();
            healthyMax = activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_MAX.getName()).getIntValue();
            healthyLoseYear = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_LOSE_YEAR.getName()).getValue(), "\\|");
            healthyLoseSell = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_LOSE_SELL.getName()).getValue(), "\\|");
            healthyLoseOut = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_LOSE_OUT.getName()).getValue(), "\\|");
            //healthyIllPro = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_ILL_PRO.getName()).getValue(), "\\|");
            //healthyIllDismove = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_ILL_DISMOVE.getName()).getValue(), "\\|");
            eventPro = activityConfigMap.get(eActivityConfigType.BIGSHOP_EVENT_PRO.getName()).getIntValue();
            eventWeight = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_EVENT_WEIGHT.getName()).getValue(), "\\|");
            eventBirthdayMoneyParam = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_EVENT_BIRTHDAY_MONEY_PARAM.getName()).getValue(), "\\|");
            outAddNum = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_ADD_NUM.getName()).getValue(), "\\|");
            outMax = activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_MAX.getName()).getIntValue();
            //outWeightPlace = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_WEIGHT_PLACE.getName()).getValue(), "\\|");
            //outWeightHospital = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_WEIGHT_HOSPITAL.getName()).getValue(), "\\|");
            outParamHospital = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_PARAM_HOSPITAL.getName()).getValue(), "\\|");
            //outWeightRestaurant = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_WEIGHT_RESTAURANT.getName()).getValue(), "\\|");
            outFlopCost = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_FLOP_COST.getName()).getValue(), "\\|");
            outTreasurePriceCondition = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_TREASURE_PRICE_CONDITION.getName()).getValue(), "\\|");
            outTreasurePriceRange = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_TREASURE_PRICE_RANGE.getName()).getValue(), "\\|");
            saltBuyParam = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_SALT_BUY_PARAM.getName()).getValue(), "\\|");
            saltRisk = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_SALT_RISK.getName()).getValue(), "\\|");
            saltMineRiskSpeed = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_SALT_MINE_RISK_SPEED.getName()).getValue(), "\\|");
            dieOld = activityConfigMap.get(eActivityConfigType.BIGSHOP_DIE_OLD.getName()).getIntValue();
            eventHealthyMoneyTomuch = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_EVENT_HEALTHY_MONEY_TOMUCH.getName()).getValue(), "\\|");
            buyRandomNumList = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_BUY_RANDOM_NUM.getName()).getValue(), "\\|");
            outParamRestaurantList = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_PARAM_RESTAURANT.getName()).getValue(), "\\|");
            resultFame = activityConfigMap.get(eActivityConfigType.BIGSHOP_RESULT_FAME.getName()).getValue();
            if(activityConfigMap.containsKey(eActivityConfigType.BIGSHOP_SKILL_UP_ITEM_ID.getName())){
                beautySkillUpgradeItemId = activityConfigMap.get(eActivityConfigType.BIGSHOP_SKILL_UP_ITEM_ID.getName()).getIntValue();
            }
            beautyExLvList = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_SKILL_BEAUTY_EX_LV.getName()).getValue(), "\\|");
            buyRandomPro = activityConfigMap.get(eActivityConfigType.BIGSHOP_BUY_RANDOM_PRO.getName()).getIntValue();

            //industryBrokeParam = activityConfigMap.get(eActivityConfigType.BIGSHOP_INDUSTRY_BROKE_PARAM.getName()).getIntValue();

            outTreasurePriceWeight = StringUtils.stringToIntegerList(activityConfigMap.get(eActivityConfigType.BIGSHOP_OUT_TREASURE_PRICE_WEIGHT.getName()).getValue(), "\\|");
            healthyChangeYear = StringUtils.stringToStringList(activityConfigMap.get(eActivityConfigType.BIGSHOP_HEALTHY_CHANGE_YEAR.getName()).getValue(), "\\|");

            //配置校验

        }

        return true;
    }

    public int getFreeNum() {
        return freeNum;
    }

    public void setFreeNum(int freeNum) {
        this.freeNum = freeNum;
    }

    public int getOpenItemId() {
        return openItemId;
    }

    public void setOpenItemId(int openItemId) {
        this.openItemId = openItemId;
    }

    public int getOpenItemNum() {
        return openItemNum;
    }

    public void setOpenItemNum(int openItemNum) {
        this.openItemNum = openItemNum;
    }

    public int getBagCellBiginNum() {
        return bagCellBiginNum;
    }

    public void setBagCellBiginNum(int bagCellBiginNum) {
        this.bagCellBiginNum = bagCellBiginNum;
    }

    public int getBagCellMax() {
        return bagCellMax;
    }

    public void setBagCellMax(int bagCellMax) {
        this.bagCellMax = bagCellMax;
    }

    public List<Long> getBagCellCostList() {
        return bagCellCostList;
    }

    public void setBagCellCostList(List<Long> bagCellCostList) {
        this.bagCellCostList = bagCellCostList;
    }

    public List<Integer> getBagCellBuyNumList() {
        return bagCellBuyNumList;
    }

    public void setBagCellBuyNumList(List<Integer> bagCellBuyNumList) {
        this.bagCellBuyNumList = bagCellBuyNumList;
    }

    public List<Integer> getBirthFamily() {
        return birthFamily;
    }

    public void setBirthFamily(List<Integer> birthFamily) {
        this.birthFamily = birthFamily;
    }

    public int getBirthOld() {
        return birthOld;
    }

    public void setBirthOld(int birthOld) {
        this.birthOld = birthOld;
    }

    public long getBirthMoney() {
        return birthMoney;
    }

    public void setBirthMoney(long birthMoney) {
        this.birthMoney = birthMoney;
    }

    public int getHealthyMax() {
        return healthyMax;
    }

    public void setHealthyMax(int healthyMax) {
        this.healthyMax = healthyMax;
    }

    public List<Integer> getHealthyLoseYear() {
        return healthyLoseYear;
    }

    public void setHealthyLoseYear(List<Integer> healthyLoseYear) {
        this.healthyLoseYear = healthyLoseYear;
    }

    public List<Integer> getHealthyLoseSell() {
        return healthyLoseSell;
    }

    public void setHealthyLoseSell(List<Integer> healthyLoseSell) {
        this.healthyLoseSell = healthyLoseSell;
    }

    public List<Integer> getHealthyLoseOut() {
        return healthyLoseOut;
    }

    public void setHealthyLoseOut(List<Integer> healthyLoseOut) {
        this.healthyLoseOut = healthyLoseOut;
    }

    public List<String> getHealthyIllPro() {
        return healthyIllPro;
    }

    public void setHealthyIllPro(List<String> healthyIllPro) {
        this.healthyIllPro = healthyIllPro;
    }

    public List<Integer> getHealthyIllDismove() {
        return healthyIllDismove;
    }

    public void setHealthyIllDismove(List<Integer> healthyIllDismove) {
        this.healthyIllDismove = healthyIllDismove;
    }

    public int getEventPro() {
        return eventPro;
    }

    public void setEventPro(int eventPro) {
        this.eventPro = eventPro;
    }

    public List<String> getEventWeight() {
        return eventWeight;
    }

    public void setEventWeight(List<String> eventWeight) {
        this.eventWeight = eventWeight;
    }

    public List<String> getEventBirthdayMoneyParam() {
        return eventBirthdayMoneyParam;
    }

    public void setEventBirthdayMoneyParam(List<String> eventBirthdayMoneyParam) {
        this.eventBirthdayMoneyParam = eventBirthdayMoneyParam;
    }

    public List<Integer> getOutAddNum() {
        return outAddNum;
    }

    public void setOutAddNum(List<Integer> outAddNum) {
        this.outAddNum = outAddNum;
    }

    public int getOutMax() {
        return outMax;
    }

    public void setOutMax(int outMax) {
        this.outMax = outMax;
    }

    public List<Integer> getOutWeightPlace() {
        return outWeightPlace;
    }

    public void setOutWeightPlace(List<Integer> outWeightPlace) {
        this.outWeightPlace = outWeightPlace;
    }

    public List<String> getOutWeightHospital() {
        return outWeightHospital;
    }

    public void setOutWeightHospital(List<String> outWeightHospital) {
        this.outWeightHospital = outWeightHospital;
    }

    public List<Integer> getOutParamHospital() {
        return outParamHospital;
    }

    public void setOutParamHospital(List<Integer> outParamHospital) {
        this.outParamHospital = outParamHospital;
    }

    public List<String> getOutWeightRestaurant() {
        return outWeightRestaurant;
    }

    public void setOutWeightRestaurant(List<String> outWeightRestaurant) {
        this.outWeightRestaurant = outWeightRestaurant;
    }

    public List<Integer> getOutFlopCost() {
        return outFlopCost;
    }

    public void setOutFlopCost(List<Integer> outFlopCost) {
        this.outFlopCost = outFlopCost;
    }

    public List<Integer> getOutTreasurePriceCondition() {
        return outTreasurePriceCondition;
    }

    public void setOutTreasurePriceCondition(List<Integer> outTreasurePriceCondition) {
        this.outTreasurePriceCondition = outTreasurePriceCondition;
    }

    public List<String> getOutTreasurePriceRange() {
        return outTreasurePriceRange;
    }

    public void setOutTreasurePriceRange(List<String> outTreasurePriceRange) {
        this.outTreasurePriceRange = outTreasurePriceRange;
    }

    public List<Integer> getSaltBuyParam() {
        return saltBuyParam;
    }

    public void setSaltBuyParam(List<Integer> saltBuyParam) {
        this.saltBuyParam = saltBuyParam;
    }

    public List<String> getSaltRisk() {
        return saltRisk;
    }

    public void setSaltRisk(List<String> saltRisk) {
        this.saltRisk = saltRisk;
    }

    public List<String> getSaltMineRiskSpeed() {
        return saltMineRiskSpeed;
    }

    public void setSaltMineRiskSpeed(List<String> saltMineRiskSpeed) {
        this.saltMineRiskSpeed = saltMineRiskSpeed;
    }

    public int getDieOld() {
        return dieOld;
    }

    public void setDieOld(int dieOld) {
        this.dieOld = dieOld;
    }

    public List<Integer> getEventHealthyMoneyTomuch() {
        return eventHealthyMoneyTomuch;
    }

    public List<Integer> getBuyRandomNumList() {
        return buyRandomNumList;
    }

    public int getBeautySkillUpgradeItemId() {
        return beautySkillUpgradeItemId;
    }

    public List<Integer> getOutParamRestaurantList() {
        return outParamRestaurantList;
    }

    public GreatTradeTitleInfo getTitleInfoByAssets(String assets) {
        BigInteger bigAssets = new BigInteger(assets);
        GreatTradeTitleInfo temp = titleInfoList.get(0);
        for (int i = 0; i < titleInfoList.size() - 1; i++) {
            GreatTradeTitleInfo titleInfo = titleInfoList.get(i);
            if(bigAssets.compareTo(titleInfo.getUpgradeLimit()) >= 0){
                temp = titleInfoList.get(i + 1);
            }
        }
        return temp;
    }

    public Property getTitleRewardByTitleId(int beforeId, int afterId){
        Property titleReward = new Property();
        for (GreatTradeTitleInfo titleInfo : titleInfoList) {
            if(titleInfo.getId() >= beforeId && titleInfo.getId() < afterId){
                titleReward.addProperty(PropertyHelper.parseStringToProperty(titleInfo.getReward()));
            }
        }
        return titleReward;
    }

    public Property getEndRewardByTitleId(int beforeId, int afterId){
        Property reward = new Property();
        for (GreatTradeTitleInfo titleInfo : titleInfoList) {
            if(titleInfo.getId() >= beforeId && titleInfo.getId() < afterId){
                reward.addProperty(PropertyHelper.parseStringToProperty(titleInfo.getEndReward()));
            }
        }
        return reward;
    }

    public GreatTradeTitleInfo getGreatTradeTitleInfo(int id){
        for (GreatTradeTitleInfo titleInfo : titleInfoList) {
            if(titleInfo.getId() == id){
                return titleInfo;
            }
        }
        return null;
    }

    public List<GreatTradeGoodsInfo> getGoodsInfoListByType(int type) {
        List<GreatTradeGoodsInfo> list = new ArrayList<>();
        for (GreatTradeGoodsInfo info : goodsInfoList) {
            if(info.getType() == type){
                list.add(info);
            }
        }
        return list;
    }

    public List<GreatTradeGoodsInfo> getGoodsInfoListByAgeAndAssets(GreatTradeSimpleStatus simpleStatus) {
        List<GreatTradeGoodsInfo> list = new ArrayList<>();
        BigInteger assets = new BigInteger(simpleStatus.getAssets());
        BigInteger maxAssets = new BigInteger(simpleStatus.getMaxAssets());
        if(maxAssets.compareTo(assets) > 0){
            assets = maxAssets;
        }
        for (GreatTradeGoodsInfo info : goodsInfoList) {
            if(info.getType() != 1){
                continue;
            }
            List<Long> exParamList = StringUtils.stringToLongList(info.getExParam(), "\\|");
            if(simpleStatus.getAge() < exParamList.get(0) && assets.compareTo(BigInteger.valueOf(exParamList.get(1))) < 0){
                continue;
            }
            list.add(info);
        }
        return list;
    }

    public List<GreatTradeEventInfo> getGreatTradeEventInfoByType(int type){
        List<GreatTradeEventInfo> list = new ArrayList<>();
        for (GreatTradeEventInfo eventInfo : eventInfoList) {
            if(eventInfo.getType() == type){
                list.add(eventInfo);
            }
        }
        return list;
    }

    public GreatTradeEventInfo getGreatTradeEventInfo(int id){
        for (GreatTradeEventInfo eventInfo : eventInfoList) {
            if(eventInfo.getId() == id){
                return eventInfo;
            }
        }
        return null;
    }

    public int getRandomSaltRisk(Random random){
        List<Integer> vList = new ArrayList<>();
        List<Integer> wList = new ArrayList<>();
        for (String s : saltRisk) {
            List<Integer> list = StringUtils.stringToIntegerList(s, ";");
            vList.add(list.get(1));
            wList.add(list.get(0));
        }
        int idx = RandomHelper.getRandomIndexByWeight(wList, random);
        return vList.get(idx);
    }

    public List<Integer> getExploitSpeedRisk(int type){
        String str = saltMineRiskSpeed.get(type);
        return StringUtils.stringToIntegerList(str, ";");
    }

    /**
     * 获取解锁的玩法
     */
    public List<Integer> getUnLockType(int titleId){
        List<Integer> unLockList = new ArrayList<>();
        for (GreatTradeTitleInfo titleInfo : titleInfoList) {
            if(titleId >= titleInfo.getId()){
                unLockList.add(titleInfo.getUnlock());
            }
        }
        return unLockList;
    }

    /**
     * 根据年龄获取健康变化
     */
    public int getHealthChangeByAge(int age){
        int change = 0;
        for (String param2 : getHealthyChangeYear()) {
            List<Integer> rangeList = StringUtils.stringToIntegerList(param2, ";");
            if(age >= rangeList.get(0)){
                change = rangeList.get(1);
            }
        }
        return change;
    }

    /**
     * 根据名望获取可购买盐场个数
     */
    public int getBuySaltWorksLimit(long prestige){
        int limit = 1;
        List<String> param1 = StringUtils.stringToStringList(getResultFame(), "\\|");
        for (String param2 : param1) {
            List<Long> rangeList = StringUtils.stringToLongList(param2, ";");
            if(prestige >= rangeList.get(0)){
                limit = rangeList.get(2).intValue();
            }
        }
        return limit;
    }

    /**
     * 根据名望区间获取赌石的购买价格
     */
    public BigInteger getTreasurePriceByPrestige(long prestige, Random random, UserGreatTradeData userData) {
        int idx = 0;
        for (int i = 0; i < getOutTreasurePriceCondition().size(); i++) {
            if(prestige < getOutTreasurePriceCondition().get(i)){
                break;
            }
            idx = i;
        }
        List<Integer> priceRangeList;
        if(idx == 0) {
            priceRangeList = StringUtils.stringToIntegerList(getOutTreasurePriceRange().get(idx), ";");
        }else {
            List<Integer> weight = new ArrayList<>();
            for (int i = 0; i < idx; i++) {
                weight.add(getOutTreasurePriceWeight().get(i));
            }
            idx = RandomHelper.getRandomIndexByWeight(weight, random);
            priceRangeList = StringUtils.stringToIntegerList(getOutTreasurePriceRange().get(idx), ";");
        }
        int addition;
        if(priceRangeList.get(0).equals(priceRangeList.get(1))){
            addition = priceRangeList.get(0);
        }else {
            addition = priceRangeList.get(0) + random.nextInt(priceRangeList.get(1) - priceRangeList.get(0));
        }

        return GreatTradeMgr.toPositive(new BigDecimal(GreatTradeMgr.getCalAbleAssets(userData.getTradeStatus().getAssets()))
                .multiply(BigDecimal.valueOf(addition))
                .divide(BigDecimal.valueOf(1000), 0, BigDecimal.ROUND_DOWN).toBigInteger());
    }

    public List<Integer> getSkillListByBeautyId(int beautyId){
        List<Integer> list = new ArrayList<>();
        for (GreatTradeSkillsInfo skillsInfo : skillsInfoList) {
            if(beautyId == skillsInfo.getBeauty()){
                list.add(skillsInfo.getId());
            }
        }
        return list;
    }

    /**
     * 根据技能获得加成
     * @param skillId 技能id
     * @param skillLv 技能等级
     * @param obj 对照值
     * @param random 随机
     * @return 固定值或者千分比
     */
    public int getSkillAddition(int skillId, int skillLv, Object obj, Random random){
        int addition = 0;
        GreatTradeSkillsInfo skillsInfo = getGreatTradeSkillsInfo(skillId, skillLv);
        if(skillsInfo == null){
            return addition;
        }
        if(skillsInfo.getId() == 1){
            //现银
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 2){
            //仓库容量
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 3){
            //每年回复健康值
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 4){
            //商品刷新概率提升、大涨率提升
            int idx = (int)obj;
            return skillsInfo.getSkillParam().get(idx);
        }else if(skillsInfo.getId() == 5 || skillsInfo.getId() == 6 || skillsInfo.getId() == 7){
            //行商卖出增收
            int goodsId = (int)obj;
            for(int i = 1; i < skillsInfo.getSkillParam().size(); i++){
                if(skillsInfo.getSkillParam().get(i).equals(goodsId)){
                    return skillsInfo.getSkillParam().get(0);
                }
            }
        }else if(skillsInfo.getId() == 8){
            //提升健康最大值
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 9){
            //产业利润千分比
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 10){
            //盐场储能提升千分比
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 11){
            //特定盐场不会被查封, 1为被保护
            int saltWorksId = (int)obj;
            for (int param : skillsInfo.getSkillParam()) {
                if(saltWorksId ==  param){
                    return 1;
                }
            }
        }else if(skillsInfo.getId() == 12){
            //每n年增加m 外出次数
            int year = (int)obj;
            if((year) % skillsInfo.getSkillParam().get(0) == 0) {
                return skillsInfo.getSkillParam().get(1);
            }
        }else if(skillsInfo.getId() == 13){
            //大涨价格额外增加千分比
            return skillsInfo.getSkillParam().get(0);
        }else if(skillsInfo.getId() == 14){
            //黑市利润额外增加千分比
            return skillsInfo.getSkillParam().get(0);
        }
        return addition;
    }

    public int countAllAreaEvent() {
        List<GreatTradeEventInfo> randomList = getGreatTradeEventInfoByType(7);
        return eventInfoList.size() - randomList.size();
    }

    public List<Integer> getBeautyExLvList() {
        return beautyExLvList;
    }

    public void setBeautyExLvList(List<Integer> beautyExLvList) {
        this.beautyExLvList = beautyExLvList;
    }

    public int getBuyRandomPro() {
        return buyRandomPro;
    }

    public void setBuyRandomPro(int buyRandomPro) {
        this.buyRandomPro = buyRandomPro;
    }

    public int getIndustryBrokeParam() {
        return industryBrokeParam;
    }

    public void setIndustryBrokeParam(int industryBrokeParam) {
        this.industryBrokeParam = industryBrokeParam;
    }

    public List<Integer> getOutTreasurePriceWeight() {
        return outTreasurePriceWeight;
    }

    public void setOutTreasurePriceWeight(List<Integer> outTreasurePriceWeight) {
        this.outTreasurePriceWeight = outTreasurePriceWeight;
    }

    public String getResultFame() {
        return resultFame;
    }

    public List<String> getHealthyChangeYear() {
        return healthyChangeYear;
    }

    public void setHealthyChangeYear(List<String> healthyChangeYear) {
        this.healthyChangeYear = healthyChangeYear;
    }

    public List<GreatTradeUnlockSkillInfo> getUnlockSkillInfoList() {
        return unlockSkillInfoList;
    }

    public void setUnlockSkillInfoList(List<GreatTradeUnlockSkillInfo> unlockSkillInfoList) {
        this.unlockSkillInfoList = unlockSkillInfoList;
    }
}
